package tcp_proxy_middleware

import (
	"gin-gateway/core/dao"
	"log"
	"gin-gateway/reverse_proxy"
)

func GetServiceDetail(c *reverse_proxy.TcpSliceRouterContext) *dao.ServiceDetail {
	serverInterface := c.Get("service")
	if serverInterface == nil {
		_, err := c.Conn.Write([]byte("get service empty"))
		if err != nil {
			log.Println("TCPBlackListMiddleware Write error:", err)
		}
		c.Abort()
		return nil
	}
	return serverInterface.(*dao.ServiceDetail)
}
